package com.tjakus.bean;

import java.util.List;
import com.tjakus.hibernate.HibernateUtil;
import com.tjakus.hibernate.Services;
import com.tjakus.logging.Logging;

public class ServicesBean {

	private List<Services> servicesList = HibernateUtil.getAllServices();
	private Services newService = new Services();
	private Services selectedService = new Services();

	public Services getSelectedService() {
		return selectedService;
	}

	public void setSelectedService(Services selectedService) {
		this.selectedService = selectedService;
	}

	public Services getNewService() {
		return newService;
	}

	public void setNewService(Services newService) {
		this.newService = newService;
	}

	public List<Services> getServicesList() {
		return servicesList;
	}

	public void setServicesList(List<Services> servicesList) {
		this.servicesList = servicesList;
	}

	public void add() {
		Logging.getLogger().info("ADD");
		Logging.getLogger().info("ADD - ( " + newService.getType() +  " " + newService.getSubType() + " )");
		HibernateUtil.addService(newService);
		this.setServicesList(HibernateUtil.getAllServices());
		newService = new Services();
	}
	
	public void deleteService() {
		Logging.getLogger().info("DELETE");
		Logging.getLogger().info("DELETE - ( " + selectedService.getServiceId() + " )");
		HibernateUtil.deleteService(selectedService);
		servicesList = HibernateUtil.getAllServices();
	}

}
